package gateway.server.lifecycle;

import gateway.api.aware.EngineAware;
import gateway.api.engine.Engine;

/**
 * @author Jin Zheng
 * @since 1.0 2020-09-25
 */
public class EngineLifecycle implements Lifecycle
{
	private final Engine engine;

	public EngineLifecycle(Engine engine)
	{
		this.engine = engine;
	}

	@Override
	public boolean accepted(Object target)
	{
		return target instanceof EngineAware;
	}

	@Override
	public void handle(Object target) throws Exception
	{
		EngineAware aware = (EngineAware) target;
		aware.setEngine(engine);
	}
}
